package com.itshizhan.itjidancideveloper.minio;


import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Component
public class MinioConfig {
    @Autowired
    MinioProperties minioProperties;

    @Bean
    MinioClient minioClient(){
        MinioClient minioClient = null;
        try {
            minioClient = MinioClient.builder()
                    .endpoint(minioProperties.getEndpoint())
                    .credentials(minioProperties.getAccessKey(),minioProperties.getSecretKey())
                    .build();
        }catch (Exception e){
            System.out.println("MinioClient 初始化失败…");
            e.printStackTrace();
        }
        return minioClient;
    }
}
